package com.example.controller;

import com.example.annocation.RedssionLockAspect;
import com.example.entity.User;
import org.springframework.aop.framework.AopContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author hzd
 * @date 2023/12/19 12:28
 */
@RestController
public class TestController {

    @RequestMapping("test")
    public void test() {
        TestController test = (TestController) AopContext.currentProxy();
        User user = new User();
        user.setName("123");
        user.setId(1);
        user.setAge(23);
        test.testDistributeLock(user);
    }


    @RedssionLockAspect(key = "'testRedssion'+#user.name")
    public void testDistributeLock(User user) {
        System.out.println("id--->" + user.toString());
    }
}
